/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package ims.banking;

import java.util.ArrayList;
import java.util.HashMap;

public class BankingTaskManager {
    private HashMap<String, BankAccount> accounts;
    private TaskManager taskManager;

    public BankingTaskManager() {
        accounts = new HashMap<>();
        taskManager = new TaskManager();
    }

    // Account Management
    public void createAccount(String accountNumber, double initialBalance, double annualInterestRate) {
        if (!accounts.containsKey(accountNumber)) {
            accounts.put(accountNumber, new BankAccount(initialBalance, annualInterestRate));
        }
    }

    public boolean deposit(String accountNumber, double amount) {
        BankAccount account = accounts.get(accountNumber);
        if (account != null) {
            account.deposit(amount);
            taskManager.addTask("Deposit of " + amount + " to account " + accountNumber);
            return true;
        }
        return false;
    }

    public boolean withdraw(String accountNumber, double amount) {
        BankAccount account = accounts.get(accountNumber);
        if (account != null) {
            boolean success = account.withdraw(amount);
            if (success) {
                taskManager.addTask("*Withdrawal of " + amount + " from account " + accountNumber);
            }
            return success;
        }
        return false;
    }

    public double getBalance(String accountNumber) {
        BankAccount account = accounts.get(accountNumber);
        if (account != null) {
            return account.getBalance();
        }
        return -1;  // indicates account not found
    }

    public void monthlyProcess(String accountNumber) {
        BankAccount account = accounts.get(accountNumber);
        if (account != null) {
            account.monthlyProcess();
        }
    }

    // Task Management
    public void addTask(String description) {
        taskManager.addTask(description);
    }

    public boolean removeTask(String priority, int index) {
        return taskManager.removeTask(priority, index);
    }

    public boolean changePriority(String priority, int index) {
        return taskManager.changePriority(priority, index);
    }

    public boolean promoteTask(int index) {
        return taskManager.promoteTask(index);
    }

    public ArrayList<String> listHighPriorityTasks() {
        return taskManager.getHighPriorityTasks();
    }
}
